<?php
class address
{
	function showAddress($explodedAddress, $link="")
	{
		$workdays=new workdays();
		$addrElement=explode('^', $explodedAddress);
		$address=$addrElement[0].', '.$addrElement[1];
		if(!$addrElement[1])$address=$addrElement[0];
		$phone=$addrElement[2];
		$wDays=$addrElement[4];
		if($addrElement[3]!='')$mallElement=explode(',', $addrElement[3]);
		$mallId=$mallElement[0];
		$mallName=$mallElement[1];
		$mallShort=$mallElement[2];
		echo ('
		<div class="anAddress">
			<table border="0">
				<tr>
					<td class="namesCol">
						<img src="images/address.jpg" />
					</td>
					<td width="" class="addressTd">
						 '.$address.'
					</td>
				</tr>
				<tr  align="center">
					<td colspan="2">
						 <a class="mallLink" href="malls.php?city='.$_GET['city'].'&id='.$mallId.'">'.$mallShort.' '.$mallName.'</a>
					</td>
				</tr>
				');
				if($phone)
				echo ('
				<tr>
					<td class="namesCol">
						<img src="images/phone.jpg" />
					</td>
					<td class="phoneTd">
					 '.$phone.'
					</td>
				</tr>
				');
				echo ('
				<tr>
					<td class="namesCol">
						<img src="images/clock.jpg" />
					</td>
					<td class="wdTd">
					');
						$workdays->showWorkdays($wDays);
					echo ('
					</td>
				</tr>
					');
					if(count($addressArray)>1)
					{
						echo ('
						<tr>
							<td colspan="2" class="manyAddresses" align="center">
								Имеются другие адреса
							</td>
						</tr>
						');
					}
	               echo ('
	               		<tr>
	               			<td class="namesCol">
	               				<img src="images/site.jpg" />
	               			</td>
	               			<td class="webTd">
	               		');
	               		if($link)
	               			echo '<a href="http://'.$link.'">www.'.$link.'</a>';
	               		else
	               			echo ('не указан');
	               		echo ('
	               	</td>
				</tr>
			</table>
		</div>
		');
	}
	function showSeveralAddresses($address, $link, $edit='')
	{
		$explodedAddress=explode('|', $address);
		echo ('
		<script type="text/javascript" src="http://pro-gorod.com/scripts/address.js">
		</script>
		<div id="mainAdr" style="display: block;">
		');
		if($edit)
			$this->showEditAddress($explodedAddress[0], $link);
		else
			$this->showAddress($explodedAddress[0], $link);
		if(count($explodedAddress)>1)
		{
			echo ('
				<div id="showAllLink"  style="display: block;" class="moreLink">
					Еще адреса
				</div>
			');
		}
		echo ('
		</div>
		');
			echo ('
			<div id="allAdr" style="display: none;">
			');
				//$this->showAddress($explodedAddress[0], $link, $edit);
					echo ('

					');
				//}
			for($i=1; $i<count($explodedAddress); $i++)
			{
				echo '<br />';
				$this->showAddress($explodedAddress[$i]);
			}
			echo ('
				<div id="closeAllAdr" class="moreLink">
					Закрыть
				</div>
			</div>
			');

	}
}
?>